var e = require("../../../@babel/runtime/helpers/regeneratorRuntime"),
  t = require("../../../@babel/runtime/helpers/slicedToArray"),
  a = require("../../../@babel/runtime/helpers/asyncToGenerator"),
  r = require("../../../config/index"),
  n = "https://statics.zhaogongdi.com/images/wp/",
  o = [
  //   {
  //   label: "我要求购机械",
  //   text: "购买二手机械？发布求购，实惠好机找上门",
  //   src: "".concat(n, "release1.png"),
  //   path: "/subpackage/publish/ask-buy/index",
  //   type: r.typeMode.askBuy
  // }, {
  //   label: "我要出售机械",
  //   text: "机械想转手？发布消息，机械转手分分钟",
  //   src: "".concat(n, "release2.png"),
  //   path: "/subpackage/publish/sell/index",
  //   type: r.typeMode.sell
  // }, 
  {
    label: "我要求租机械",
    text: "快速发布求租信息，机械找上门，工期不延误",
    src: "https://mp-78644cf8-2fa7-4805-8999-9c23996903e0.cdn.bspapp.com/催租涵管理备份.png",
    path: "/subpackage/publish/seeking/index",
    type: r.typeMode.seeking
  }, {
    label: "我要出租机械",
    text: "机械出租一键发布，上万好活接不完",
    src: "https://mp-78644cf8-2fa7-4805-8999-9c23996903e0.cdn.bspapp.com/1.png",
    path: "/subpackage/publish/hire/index",
    type: r.typeMode.hire
  }, {
    label: "机械驾驶员招聘",
    text: "发布驾驶员需求，海量专业驾驶员主动联系",
    src: "".concat(n, "release5.png"),
    path: "/subpackage/publish/recruit/index",
    type: r.typeMode.recruit
  }],
  s = JSON.parse(JSON.stringify(o)).map((function (e) {
    var t = e.label.substring(2);
    return e.label = "我想".concat(t), e.text = "免费发布".concat(t, "信息"), e
  }));
Component({
  useStore: function (e) {
    return {
      token: e.storage.userInfo.token,
      userInfo: e.storage.userInfo
    }
  },
  properties: {
    show: {
      type: Boolean,
      value: !1
    },
    btnText: {
      type: String,
      value: "免费发布机械信息"
    },
    mode: {
      type: "manual",
      value: "manual"
    },
    require: {
      type: Boolean,
      value: !1
    },
    origin: {
      type: String,
      value: "index"
    }
  },
  data: {
    manualList: o,
    autoList: s
  },
  methods: {
    onClose: function () {
      this.setData({
        show: !1
      }), "auto" === this.data.mode && this.reportAction("0"), this.triggerEvent("close")
    },
    getConfig: function () {
      var r = this;
      return a(e().mark((function a() {
        var n, o, s;
        return e().wrap((function (e) {
          for (;;) switch (e.prev = e.next) {
            case 0:
              if (r.data.token && "index" == r.data.origin) {
                e.next = 2;
                break
              }
              return e.abrupt("return");
            case 2:
              return e.next = 4, $.request["GET/v2/dialog/popup-notify"]({
                source: "XCX"
              });
            case 4:
              n = e.sent, o = t(n, 1), 200 === (s = o[0]).code && s.content.show_popup && r.setData({
                mode: "auto",
                show: !0,
                require: s.content.is_required
              });
            case 8:
            case "end":
              return e.stop()
          }
        }), a)
      })))()
    },
    reportAction: function (r) {
      return a(e().mark((function a() {
        var n, o, s;
        return e().wrap((function (e) {
          for (;;) switch (e.prev = e.next) {
            case 0:
              return e.next = 2, $.request["POST/v2/dialog/popup-reply?source=XCX"]({
                type: r
              }, {
                "content-type": "application/json"
              });
            case 2:
              n = e.sent, o = t(n, 1), 200 === (s = o[0]).code && console.log("data :>> ", s);
            case 6:
            case "end":
              return e.stop()
          }
        }), a)
      })))()
    },
    onClickRelease: function () {
      !this.data.userInfo.id ? "recruit" != this.data.origin ? this.setData({
        show: !0,
        mode: "manual"
      }) : $.router.push(this.data.btnText=='免费发布驾驶员招聘'?"/subpackage/publish/recruit/index":"/subpackage/publish/complain/index") : $.router.push("/subpackage/login/auth/index")
    },
    onClickItem: function (e) {
      var t = e.detail,
        a = t.path,
        phone=wx.getStorageSync('userPhone'),
        r = t.type;
        phone ? ($.router.push(a), "auto" === this.data.mode && this.reportAction(r)) : $.router.push("/subpackage/login/auth/index")
    }
  },
  lifetimes: {
    attached: function () {
      this.getConfig()
    }
  },
  pageLifetimes: {
    hide: function () {
      this.setData({
        show: !1
      })
    }
  }
});